home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Musik / Misc / Amster / Source / search.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-27  |  18.5 KB  |  687 lines

  1. /*
  2. ** Search
  3. */
  4.  
  5. #include "include/config.h"
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10.  
  11. #include <proto/dos.h>
  12.  
  13. #include "include/mui.h"
  14. #include <MUI/Lamp_mcc.h>
  15. #include <MUI/NListview_mcc.h>
  16.  
  17. #include "include/gui.h"
  18. #include "include/search.h"
  19. #include "include/protos.h"
  20. #include "include/napster.h"
  21. #include "include/download.h"
  22. #include "include/panel.h"
  23. #include "include/prefs.h"
  24. #include "amster_Cat.h"
  25. #include "include/protos.h"
  26.  
  27. ULONG search_new(struct IClass *cl, Object *obj, struct opSet *msg);
  28. MUIF songlistdisp(REG(a2) char **array, REG(a1) song s);
  29. MUIF songlistcomp(REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct NList_CompareMessage *ncm);
  30. void search_clear(struct searchdata *data);
  31. void search_download(struct searchdata *data, int t);
  32. void search_go(struct searchdata *data, char *sname);
  33. void search_nick(struct searchdata *data);
  34. void search_stat(struct searchdata *data, int t);
  35. void search_found(struct searchdata *data, song s);
  36. void search_reset(struct searchdata *data);
  37. void search_toggle(struct searchdata *data);
  38. void search_set(struct searchdata *data);
  39. void search_use(struct searchdata *data);
  40.  
  41. int search_count = 0;
  42. int search_state = 0;
  43.  
  44.  
  45. MUIF search_dispatch(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  46. {
  47.     struct searchdata *data = INST_DATA(cl,obj);
  48.  
  49.     switch(msg->MethodID) {
  50.         case OM_NEW: return(search_new(cl,obj,(APTR)msg));
  51.         case SEARCH_CLEAR:
  52.             search_clear(data);
  53.             return(0);
  54.         case SEARCH_DOWNLOAD:
  55.             search_download(data,(int)(((muimsg)msg)->arg1));
  56.             return(0);
  57.         case SEARCH_GO:
  58.             search_go(data,(char*)(((muimsg)msg)->arg1));
  59.             return(0);
  60.         case SEARCH_NICK:
  61.             search_nick(data);
  62.             return(0);
  63.         case SEARCH_FOUND:
  64.             search_found(data,(song)(((muimsg)msg)->arg1));
  65.             return(0);
  66.         case SEARCH_RESET:
  67.             search_reset(data);
  68.             return(0);
  69.         case SEARCH_REFRESH:
  70.             set(data->fptog,MUIA_Selected,prf->fullpath);
  71.             DoMethod(data->list,MUIM_NList_Redraw,MUIV_NList_Redraw_All);
  72.             return(0);
  73.         case SEARCH_TOGGLE:
  74.             search_toggle(data);
  75.             return(0);
  76.         case SEARCH_SET:
  77.             search_set(data);
  78.             return(0);
  79.         case SEARCH_GET:
  80.             search_use(data);
  81.             return(0);
  82.         case SEARCH_USE:
  83.             search_use(data);
  84.             prf_save("ENV:"AMSTER_PREFS);
  85.             DoMethod(data->pop, MUIM_Popstring_Close, TRUE);
  86.             return(0);
  87.     }
  88.     return(DoSuperMethodA(cl,obj,msg));
  89. }
  90.  
  91.  
  92. ULONG search_new(struct IClass *cl, Object *obj, struct opSet *msg)
  93. {
  94.     static char *numbers = "0123456789";
  95.     static char *opts[] = {
  96.         (char*)_MSG_COMPARE_NONE,
  97.         (char*)_MSG_COMPARE_ATLEAST,
  98.         (char*)_MSG_COMPARE_EQUALTO,
  99.         (char*)_MSG_COMPARE_ATBEST,
  100.         NULL
  101.     };
  102.     static struct Hook songlistdispHook = { {0,0}, &songlistdisp, NULL, NULL };
  103.     static struct Hook songlistcompHook = { {0,0}, &songlistcomp, NULL, NULL };
  104.     struct searchdata *data;
  105.     Object *str,*maxstr,*snick,*sbut,*nbut;
  106.     Object *pop;
  107.     Object *popspeed, *popspeedval, *popbit, *popbitval, *popfreq, *popfreqval;
  108.     Object *popuse, *popreset;
  109.     Object *result, *list;
  110.     Object *clrbut, *BT_Resume, *dlbut, *fptog;
  111.  
  112.     if(opts[0] == (char *)_MSG_COMPARE_NONE)
  113.         localize_array(opts);
  114.  
  115.     if (obj = (Object *)DoSuperNew(cl,obj,
  116.         Child, VGroup,
  117.             Child, ColGroup(2),
  118.                 Child, Label2(MSG_SEARCH),
  119.                 Child, HGroup,
  120.                     Child, str = StringObject,
  121.                         StringFrame,
  122.                         MUIA_HorizWeight, 400,
  123.                         MUIA_String_MaxLen, 80,
  124.                         MUIA_CycleChain, 1,
  125.                     End,
  126.                     Child, sbut = SimpleButton(MSG_SEARCH_GAD),
  127.                 End,
  128.                 Child, Label2(MSG_SEARCHUSER),
  129.                 Child, HGroup,
  130.                     Child, snick = StringObject,
  131.                         StringFrame,
  132.                         MUIA_HorizWeight, 400,
  133.                         MUIA_String_MaxLen, 20,
  134.                         MUIA_CycleChain, 1,
  135.                         MUIA_ShortHelp, MSG_SEARCHUSER_HELP,
  136.                     End,
  137.                     Child, nbut = SimpleButton(MSG_SEARCHUSER_GAD),
  138.                     Child, Label2(MSG_MAX),
  139.                     Child, maxstr = StringObject,
  140.                         StringFrame,
  141.                         MUIA_String_Accept, numbers,
  142.                         MUIA_String_Integer, 100,
  143.                         MUIA_String_MaxLen, 4,
  144.                         MUIA_CycleChain, 1,
  145.                     End,
  146.                     Child, pop = PopobjectObject,
  147.                         MUIA_Popstring_Button, PopButton(MUII_PopUp),
  148.                         MUIA_Popobject_Object, VGroup,
  149.                             MUIA_Frame, MUIV_Frame_PopUp,
  150.                             Child, TextObject,
  151.                                 MUIA_Text_Contents, MSG_ADVSEARCH,
  152.                             End,
  153.                             Child, ColGroup(3),
  154.                                 Child, Label2(MSG_LINESPEED),
  155.                                 Child, popspeed = CycleObject,
  156.                                     MUIA_Cycle_Active, 0,
  157.                                     MUIA_Cycle_Entries, opts,
  158.                                     MUIA_CycleChain, 1,
  159.                                 End,
  160.                                 Child, popspeedval = CycleObject,
  161.                                     MUIA_Cycle_Active, 1,
  162.                                     MUIA_Cycle_Entries, nap_linktype,
  163.                                     MUIA_CycleChain, 1,
  164.                                 End,
  165.                                 Child, Label2(MSG_BITRATE),
  166.                                 Child, popbit = CycleObject,
  167.                                     MUIA_Cycle_Active, 0,
  168.                                     MUIA_Cycle_Entries, opts,
  169.                                     MUIA_CycleChain, 1,
  170.                                 End,
  171.                                 Child, HGroup,
  172.                                     Child, popbitval = StringObject,
  173.                                         StringFrame,
  174.                                         MUIA_String_Accept, numbers,
  175.                                         MUIA_String_Integer, 128,
  176.                                         MUIA_String_MaxLen, 4,
  177.                                         MUIA_CycleChain, 1,
  178.                                     End,
  179.                                     Child, Label2(MSG_KBPS),
  180.                                 End,
  181.                                 Child, Label2(MSG_FREQUENCY),
  182.                                 Child, popfreq = CycleObject,
  183.                                     MUIA_Cycle_Active, 0,
  184.                                     MUIA_Cycle_Entries, opts,
  185.                                     MUIA_CycleChain, 1,
  186.                                 End,
  187.                                 Child, HGroup,
  188.                                     Child, popfreqval = StringObject,
  189.                                         StringFrame,
  190.                                         MUIA_String_Accept, numbers,
  191.                                         MUIA_String_Integer, 44100,
  192.                                         MUIA_String_MaxLen, 6,
  193.                                         MUIA_CycleChain, 1,
  194.                                     End,
  195.                                     Child, Label2(MSG_HZ),
  196.                                 End,
  197.                             End,
  198.                             Child, HGroup,
  199.                                 Child, popuse = SimpleButton(MSG_ADVUSE_GAD),
  200.                                 Child, HSpace(0),
  201.                                 Child, popreset = SimpleButton(MSG_ADVRESET_GAD),
  202.                             End,
  203.                         End,
  204.                     End,
  205.                 End,
  206.             End,
  207.             Child, HGroup,
  208.                 Child, Label(MSG_RESULT),
  209.                 Child, result = TextObject, End,
  210.             End,
  211.             Child, NListviewObject,
  212.                 MUIA_NListview_NList, list = NListObject,
  213.                     InputListFrame,
  214.                     MUIA_NList_Title, TRUE,
  215.                     MUIA_NList_Format, "BAR, BAR, BAR, BAR, BAR, BAR, BAR, BAR",
  216.                     MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Default,
  217.                     MUIA_NList_DisplayHook, &songlistdispHook,
  218.                     MUIA_NList_CompareHook2, &songlistcompHook,
  219.                     MUIA_CycleChain, 1,
  220.                 End,
  221.             End,
  222.             Child, HGroup,
  223.                 Child, clrbut = SimpleButton(MSG_CLEAR_GAD),
  224.                 Child, BT_Resume = SimpleButton(MSG_RESUME_GAD),
  225.                 Child, dlbut = SimpleButton(MSG_DOWNLOAD_GAD),
  226.                 Child, TextObject,
  227.                     MUIA_HorizWeight, 25,
  228.                     MUIA_Text_PreParse, "\33r",
  229.                     MUIA_Text_Contents, MSG_SEARCH_FULLPATH,
  230.                 End,
  231.                 Child, fptog = ImageObject,
  232.                     ButtonFrame,
  233.                     MUIA_HorizWeight, 10,
  234.                     MUIA_Background, MUII_ButtonBack,
  235.                     MUIA_InputMode, MUIV_InputMode_Toggle,
  236.                     MUIA_ShowSelState, FALSE,
  237.                     MUIA_Image_Spec, "6:15",
  238.                     MUIA_Selected, prf->fullpath,
  239.                 End,
  240.             End,
  241.         End,
  242.         TAG_MORE, msg->ops_AttrList))
  243.     {
  244.         data = INST_DATA(cl,obj);
  245.         data->str = str;
  246.         data->maxstr = maxstr;
  247.         data->snick = snick;
  248.         data->pop = pop;
  249.         data->popspeed = popspeed;
  250.         data->popspeedval = popspeedval;
  251.         data->popbit = popbit;
  252.         data->popbitval = popbitval;
  253.         data->popfreq = popfreq;
  254.         data->popfreqval = popfreqval;
  255.         data->result = result;
  256.         data->list = list;
  257.         data->BT_Resume = BT_Resume;
  258.         data->clrbut = clrbut;
  259.         data->dlbut = dlbut;
  260.         data->fptog = fptog;
  261.  
  262.         lamp_useinlist(list);
  263.  
  264.         DoMethod(str,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,obj,2,SEARCH_GO,NULL);
  265.         DoMethod(sbut,MUIM_Notify,MUIA_Pressed,FALSE,obj,2,SEARCH_GO,NULL);
  266.         DoMethod(snick,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,obj,1,SEARCH_NICK);
  267.         DoMethod(nbut,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,SEARCH_NICK);
  268.  
  269.         DoMethod(popuse,   MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, SEARCH_USE  );
  270.         DoMethod(popreset, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, SEARCH_RESET);
  271.  
  272.         DoMethod(clrbut, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, SEARCH_CLEAR);
  273.         DoMethod(dlbut, MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, SEARCH_DOWNLOAD, 0);
  274.         DoMethod(BT_Resume, MUIM_Notify, MUIA_Pressed, FALSE, obj, 2, SEARCH_DOWNLOAD, 2);
  275.         DoMethod(list, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 2, SEARCH_DOWNLOAD, 1);
  276.  
  277.         DoMethod(fptog,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,obj,1,SEARCH_TOGGLE);
  278.  
  279.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick,  MUIV_EveryTime, list, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  280.         DoMethod(list, MUIM_Notify, MUIA_NList_TitleClick2, MUIV_EveryTime, list, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  281.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType,    MUIV_EveryTime, list, 3, MUIM_Set, MUIA_NList_TitleMark,  MUIV_TriggerValue);
  282.         DoMethod(list, MUIM_Notify, MUIA_NList_SortType2,   MUIV_EveryTime, list, 3, MUIM_Set, MUIA_NList_TitleMark2, MUIV_TriggerValue);
  283.  
  284.         set(BT_Resume, MUIA_Disabled, TRUE);    /* Until it's implemented! */
  285.  
  286.         return((ULONG)obj);
  287.     }
  288.     return(0);
  289. }
  290.  
  291.  
  292. MUIF songlistdisp(REG(a2) char **array, REG(a1) song s)
  293. {
  294.     static char buf[50], buf2[50], buf3[50], time[40];
  295.  
  296.     if (s) {
  297.         if(s->link == 0)
  298.             *array++ = lamp_getforlist(0);
  299.         else if(s->link < 5)
  300.             *array++ = lamp_getforlist(1);
  301.         else if(s->link < 8)
  302.             *array++ = lamp_getforlist(2);
  303.         else
  304.             *array++ = lamp_getforlist(3);
  305.  
  306.         if(prf->fullpath)
  307.             *array++ = s->title;
  308.         else
  309.             *array++ = nap_strippath(s->title);
  310.  
  311.         sprintf(buf,"\33c%d",s->bit);
  312.         *array++ = buf;
  313.         sprintf(buf2,"\33c%d",s->freq);
  314.         *array++ = buf2;
  315.         sprintf(buf3,"\33r%ld",s->size);
  316.         *array++ = buf3;
  317.  
  318.         if(s->time>0) {
  319.             int secs = s->size/(s->bit*125);
  320.             if(abs(s->time - secs)*100/s->time > 3)
  321.                 sprintf(time,"\33r\33i%ld:%02ld",s->time/60,s->time%60);
  322.             else
  323.                 sprintf(time,"\33r%ld:%02ld",s->time/60,s->time%60);
  324.         } else {
  325.             sprintf(time,"\33r0:00");
  326.         }
  327.         *array++ = time;
  328.  
  329.         *array++ = s->user;
  330.         *array = nap_linktype[s->link];
  331.     } else {
  332.         *array++ = "\33c@";
  333.         *array++ = (char *)MSG_LH_SONG;
  334.         *array++ = (char *)MSG_LH_KBPS;
  335.         *array++ = (char *)MSG_LH_HZ;
  336.         *array++ = (char *)MSG_LH_SIZE;
  337.         *array++ = (char *)MSG_LH_TIME;
  338.         *array++ = (char *)MSG_LH_USER;
  339.         *array = (char *)MSG_LH_LINK;
  340.     }
  341.     return(0);
  342. }
  343.  
  344.  
  345. void search_clear(struct searchdata *data)
  346. {
  347.     u_long item;
  348.  
  349.     set(data->list, MUIA_NList_Quiet, MUIV_NList_Quiet_Visual);
  350.     while (1) {
  351.         DoMethod(data->list, MUIM_NList_GetEntry, 0, &item);
  352.         if (!item) break;
  353.         DoMethod(data->list, MUIM_NList_Remove, MUIV_NList_Remove_First);
  354.         nap_songfree((song)item);
  355.     }
  356.     set(data->list, MUIA_NList_Quiet, MUIV_NList_Quiet_None);
  357.     search_stat(data, 0);
  358. }
  359.  
  360.  
  361. void search_download(struct searchdata *data, int t)
  362. {
  363.     int f=0;
  364.     u_long item, listid;
  365.  
  366.     if (!gui_napon) return;
  367.  
  368.     switch (t) {
  369.         case 0:
  370.             listid = MUIV_NList_NextSelected_Start;
  371.             for (;;) {
  372.                 DoMethod(data->list, MUIM_NList_NextSelected, &listid);
  373.                 if (listid == MUIV_NList_NextSelected_End) break;
  374.                 DoMethod(data->list, MUIM_NList_GetEntry, listid, &item);
  375.                 if (item) {
  376.                     if (!f) {
  377.                         DoMethod(gui->iconpanel, PANEL_OPENDL);
  378.                         f=1;
  379.                     }
  380.                     sprintf(nap_buf, "\"%s\" \"%s\"", ((song)item)->user, ((song)item)->title);
  381.                     nap_send(NAPC_FILEINFOREQ);
  382.                     dl_addq((song)item);
  383.                 }
  384.             }
  385.             break;
  386.  
  387.         case 1:
  388.             GetAttr(MUIA_NList_DoubleClick, data->list, &listid);
  389.             if (listid == -1 || listid == -2) return;
  390.             DoMethod(data->list, MUIM_NList_GetEntry, listid, &item);
  391.             if (!item) return;
  392.             if (!f) {
  393.                 DoMethod(gui->iconpanel, PANEL_OPENDL);
  394.                 f=1;
  395.             }
  396.             sprintf(nap_buf, "\"%s\" \"%s\"", ((song)item)->user, ((song)item)->title);
  397.             nap_send(NAPC_FILEINFOREQ);
  398.             dl_addq((song)item);
  399.             break;
  400.  
  401.         case 2:
  402.             DoMethod(data->list, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &item);
  403.             if (!item) return;
  404. gui_debugf("Resume attempted for: %s", ((song)item)->title);
  405.             break;
  406.     }
  407. }
  408.  
  409.  
  410. void search_go(struct searchdata *data, char *sname)
  411. {
  412.     static char *opts[] = {
  413.         "AT LEAST",
  414.         "EQUAL TO",
  415.         "AT BEST"
  416.     };
  417.     char *p, str[80];
  418.     u_long tmp,tmp2;
  419.  
  420.     if(!gui_napon) return;
  421.  
  422.     if(sname) {
  423.         tmp = (u_long)sname;
  424.     } else {
  425.         GetAttr(MUIA_String_Acknowledge,data->str,&tmp);
  426.         if(!tmp || ((char*)tmp)[0]==0) return;
  427.     }
  428.     GetAttr(MUIA_String_Integer,data->maxstr,&tmp2);
  429.     if(tmp2<3) tmp2=3;
  430. /*    if(tmp2>100) tmp2=100;*/
  431.     strcpy(str,(char*)tmp);
  432.     strlwr(str);
  433.     p = nap_buf + sprintf(nap_buf,"FILENAME CONTAINS \"%s\" MAX_RESULTS %d",str,tmp2);
  434.  
  435.     GetAttr(MUIA_Cycle_Active,data->popspeed,&tmp);
  436.     GetAttr(MUIA_Cycle_Active,data->popspeedval,&tmp2);
  437.     if(tmp) p=p+sprintf(p," LINESPEED \"%s\" %d",opts[tmp-1],tmp2);
  438.  
  439.     GetAttr(MUIA_Cycle_Active,data->popbit,&tmp);
  440.     GetAttr(MUIA_String_Integer,data->popbitval,&tmp2);
  441.     if(tmp) p=p+sprintf(p," BITRATE \"%s\" %d",opts[tmp-1],tmp2);
  442.  
  443.     GetAttr(MUIA_Cycle_Active,data->popfreq,&tmp);
  444.     GetAttr(MUIA_String_Integer,data->popfreqval,&tmp2);
  445.     if(tmp) sprintf(p," FREQ \"%s\" %d",opts[tmp-1],tmp2);
  446.  
  447.     search_count=0;
  448.     if(prf->clrlist) search_clear(data);
  449.     search_stat(data,1);
  450.     nap_send(NAPC_SEARCH);
  451. }
  452.  
  453.  
  454. void search_nick(struct searchdata *data)
  455. {
  456.     u_long tmp;
  457.  
  458.     if (!gui_napon) return;
  459.     GetAttr(MUIA_String_Acknowledge, data->snick, &tmp);
  460.     if (tmp && ((char *)tmp)[0] != '\0') {
  461.         search_count=0;
  462.         if (prf->clrlist) search_clear(data);
  463.         nap_sendbuf(NAPC_BROWSEUSER, (char *)tmp);
  464.         search_stat(data, 3);
  465.     }
  466. }
  467.  
  468.  
  469. void search_stat(struct searchdata *data, int t)
  470. {
  471.     static char buf[80];
  472.     char *txt;
  473.  
  474.     switch(t) {
  475.         case 0:
  476.             txt = "";
  477.             search_state = 0;
  478.             break;
  479.  
  480.         case 1:
  481.             search_state = 1;
  482.             txt = (char*)MSG_STATUS1_SEARCHING;
  483.             break;
  484.  
  485.         case 2:
  486.             if(search_count==0)
  487.                 txt = (char*)MSG_STATUS1_NOFILES;
  488.             else if(search_count==1)
  489.                 txt = (char*)MSG_STATUS1_ONEFOUND;
  490.             else {
  491.                 sprintf(buf,MSG_STATUS1_FOUND,search_count);
  492.                 txt = buf;
  493.             }
  494.             search_state = 2;
  495.             break;
  496.  
  497.         case 3:
  498.             txt = (char*)MSG_STATUS1_REQLIST;
  499.             break;
  500.     }
  501.  
  502.     set(data->result,MUIA_Text_Contents,txt);
  503. }
  504.  
  505.  
  506. void search_found(struct searchdata *data, song s)
  507. {
  508.     if(s) {
  509.         DoMethod(data->list,MUIM_NList_InsertSingle,s,MUIV_NList_Insert_Sorted);
  510.         search_count++;
  511.     } else {
  512.         search_stat(data,2);
  513.     }
  514. }
  515.  
  516.  
  517. void search_reset(struct searchdata *data)
  518. {
  519.     set(data->popspeed,MUIA_Cycle_Active,0);
  520.     set(data->popspeedval,MUIA_Cycle_Active,1);
  521.     set(data->popbit,MUIA_Cycle_Active,0);
  522.     set(data->popbitval,MUIA_String_Integer,128);
  523.     set(data->popfreq,MUIA_Cycle_Active,0);
  524.     set(data->popfreqval,MUIA_String_Integer,44100);
  525. }
  526.  
  527.  
  528. void search_toggle(struct searchdata *data)
  529. {
  530.     u_long tmp;
  531.  
  532.     GetAttr(MUIA_Selected,data->fptog,&tmp);
  533.     prf->fullpath = tmp;
  534.  
  535.  
  536.     DoMethod(data->list,MUIM_NList_Redraw,MUIV_NList_Redraw_All);
  537. }
  538.  
  539.  
  540. void search_set(struct searchdata *data)
  541. {
  542.     set(data->maxstr,      MUIA_String_Integer, prf->max);
  543.     set(data->popspeed,    MUIA_Cycle_Active,   prf->speedqual);
  544.     set(data->popspeedval, MUIA_Cycle_Active,   prf->speedval);
  545.     set(data->popbit,      MUIA_Cycle_Active,   prf->bitratequal);
  546.     set(data->popbitval,   MUIA_String_Integer, prf->bitrateval);
  547.     set(data->popfreq,     MUIA_Cycle_Active,   prf->freqqual);
  548.     set(data->popfreqval,  MUIA_String_Integer, prf->freqval);
  549. }
  550.  
  551.  
  552. void search_use(struct searchdata *data)
  553. {
  554.     u_long tmp;
  555.  
  556.     GetAttr(MUIA_Cycle_Active,data->popspeed,&tmp);
  557.     prf->speedqual = tmp;
  558.  
  559.     GetAttr(MUIA_Cycle_Active,data->popspeedval,&tmp);
  560.     prf->speedval = tmp;
  561.  
  562.     GetAttr(MUIA_Cycle_Active,data->popbit,&tmp);
  563.     prf->bitratequal = tmp;
  564.  
  565.     GetAttr(MUIA_String_Integer,data->popbitval,&tmp);
  566.     prf->bitrateval = (int)tmp;
  567.  
  568.     GetAttr(MUIA_Cycle_Active,data->popfreq,&tmp);
  569.     prf->freqqual = tmp;
  570.  
  571.     GetAttr(MUIA_String_Integer,data->popfreqval,&tmp);
  572.     prf->freqval = (int)tmp;
  573.  
  574.     GetAttr(MUIA_String_Integer,data->maxstr,&tmp);
  575.     prf->max = (int)tmp;
  576. }
  577.  
  578.  
  579. MUIF songlistcomp(REG(a0) struct Hook *hook, REG(a2) Object *obj, REG(a1) struct NList_CompareMessage *ncm)
  580. {
  581.     song entry1 = ncm->entry1;
  582.     song entry2 = ncm->entry2;
  583.     LONG col1 = ncm->sort_type & MUIV_NList_TitleMark_ColMask;
  584.     LONG col2 = ncm->sort_type2 & MUIV_NList_TitleMark2_ColMask;
  585.     ULONG result = 0;
  586.  
  587.     if (ncm->sort_type == MUIV_NList_SortType_None) return (0);
  588.  
  589.     if (col1 == 1) {
  590.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask) {
  591.             if (prf->fullpath) result = (LONG) stricmp(entry2->title, entry1->title);
  592.             else result = (LONG) stricmp(nap_strippath(entry2->title), nap_strippath(entry1->title));
  593.         }
  594.         else {
  595.             if (prf->fullpath) result = (LONG) stricmp(entry1->title, entry2->title);
  596.             else result = (LONG) stricmp(nap_strippath(entry1->title), nap_strippath(entry2->title));
  597.         }
  598.     }
  599.     else if (col1 == 2) {
  600.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  601.             result = entry2->bit - entry1->bit;
  602.         else
  603.             result = entry1->bit - entry2->bit;
  604.     }
  605.     else if (col1 == 3) {
  606.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  607.             result = entry2->freq - entry1->freq;
  608.         else
  609.             result = entry1->freq - entry2->freq;
  610.     }
  611.     else if (col1 == 4) {
  612.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  613.             result = entry2->size - entry1->size;
  614.         else
  615.             result = entry1->size - entry2->size;
  616.     }
  617.     else if (col1 == 5) {
  618.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  619.             result = entry2->time - entry1->time;
  620.         else
  621.             result = entry1->time - entry2->time;
  622.     }
  623.     else if (col1 == 6) {
  624.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  625.             result = (LONG) stricmp(entry2->user, entry1->user);
  626.         else
  627.             result = (LONG) stricmp(entry1->user, entry2->user);
  628.     }
  629.     else if (col1 == 7) {
  630.         if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask)
  631.             result = entry2->link - entry1->link;
  632.         else
  633.             result = entry1->link - entry2->link;
  634.     }
  635.  
  636.     if ((result != 0) || (col1 == col2)) return (result);
  637.  
  638.     if (col2 == 1) {
  639.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask) {
  640.             if (prf->fullpath) result = (LONG) stricmp(entry2->title, entry1->title);
  641.             else result = (LONG) stricmp(nap_strippath(entry2->title), nap_strippath(entry1->title));
  642.         }
  643.         else {
  644.             if (prf->fullpath) result = (LONG) stricmp(entry1->title, entry2->title);
  645.             else result = (LONG) stricmp(nap_strippath(entry1->title), nap_strippath(entry2->title));
  646.         }
  647.     }
  648.     else if (col2 == 2) {
  649.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  650.             result = entry2->bit - entry1->bit;
  651.         else
  652.             result = entry1->bit - entry2->bit;
  653.     }
  654.     else if (col2 == 3) {
  655.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  656.             result = entry2->freq - entry1->freq;
  657.         else
  658.             result = entry1->freq - entry2->freq;
  659.     }
  660.     else if (col2 == 4) {
  661.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  662.             result = entry2->size - entry1->size;
  663.         else
  664.             result = entry1->size - entry2->size;
  665.     }
  666.     else if (col2 == 5) {
  667.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  668.             result = entry2->time - entry1->time;
  669.         else
  670.             result = entry1->time - entry2->time;
  671.     }
  672.     else if (col2 == 6) {
  673.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  674.             result = (LONG) stricmp(entry2->user, entry1->user);
  675.         else
  676.             result = (LONG) stricmp(entry1->user, entry2->user);
  677.     }
  678.     else if (col2 == 7) {
  679.         if (ncm->sort_type & MUIV_NList_TitleMark2_TypeMask)
  680.             result = entry2->link - entry1->link;
  681.         else
  682.             result = entry1->link - entry2->link;
  683.     }
  684.  
  685.     return (result);
  686. }
  687.